a t e v a n s . c o m

(╯°□°)╯︵ <ǝlqɐʇ/>

I’d really prefer not to fork the language; I’d much rather collectively help carry the banner of Markdown forward into the future, with the blessing of John Gruber and in collaboration with other popular sites that use Markdown.

So … who’s with me?

I’ve been thinking about this a bunch. Obviously, we use Markdown quite a bit at Jekyllhub. But, since Gruber hasn’t offered any kind of endorsement, I think it’s highly likely this will end up as a the n+1th format. As one HN commenter pointed out, Jeff makes no mention of MultiMarkDown, which has a test suite and compatibility guide.

Jekyllhub might add support for Rockdown / Markdown v2 / etc… I’ll probably stick close to whatever Github Pages does. As long as it’s a useable, simple format that clearly and cleanly compiles to HTML I think it will be a good fit for us.

On Monday, I moved to Kansas City, MO as part of the Homes for Hackers program. I’m staying in the attic of a local pair of cats and their two humans. On wednesday I got to check out the 1 Million Cups event at the Kauffman Foundation and see presentations from Fannect and Tappecue, as well as meeting a few investors and local entrepeneurs.

Coming directly from the downtown San Francisco scene, things here seem small but organized and ambitious. The offices I got to see in the Hanover Heights neighborhood are every bit the scrappy, idea-paint-coated mess of directions SF offices are. While I didn’t get to explore too much of the neighborhood, I’m given to understand there is both excellent coffee and excellent BBQ in walking distance. Everyone I’ve met so far has been insightful, ambitious, and clever. Lots of smart ideas cross-pollinating, and it’s easy even for a relatively shy guy like myself to get enthused.

I’m looking forward to participating more in the program and in the Kansas City Startup Village, and helping out where I can. I encourage everyone to check it out!

        bucket = AWS::S3::Bucket.find('the bucket name')
         
        while(!bucket.empty?)
        begin
        puts "Deleting objects in bucket"
        
        bucket.objects.each do |object|
        object.delete
        puts "There are #{bucket.objects.size} objects left in the bucket"
        end
        
        puts "Done deleting objects"
        
        rescue SocketError
        puts "Had socket error"
        end
        
        end

Quick loop to empty out your s3 bucket. Thanks to MattLor

We published most of our reusable capistrano recipes and you can take advantage of them here: https://github.com/PagerDuty/pd-cap-recipes

Useful batch of capistrano recipes, and a good description of how to measure & reduce deploy times. Thanks, PagerDuty!

While making GaymerCon we knew location search would be a priority. In all the gaymer meetups we’ve seen, awesome people who never would have found each other any other way have been brought together.

But you get tired of writing the same get_nearby_x query over and over. Wouldn’t it be nicer if there were just a mixin that could handle all that jazz? Well, enter Locatable:

        module Locatable
          
          def self.included(base)
            base.extend(ClassMethods)
          end
          
          def location
            @location ||= Location.find_or_create_by(item_id: self.id, item_class: self.class.name.underscore)
            @location
          end
          
          def place=(new_place)
            prev_place = self.location.place
            return if prev_place == new_place
            coords = PlaceFinder.coords(new_place)
            location.place = new_place
            location.coords = coords
            location.save
          end
          
          def place
            self.location.place
          end
          
          def coords=(new_coords)
            raise ArgumentError.new("Coordinates must by a [lat, lng] array!") unless new_coords.is_a?(Array) && new_coords.count == 2
            return true if location.coords == new_coords
            location.coords = new_coords
            location.save
          end
          
          def coords
            return nil if location.coords == [199.9, 199.9]
            location.coords
          end
          
          def distance_from(point_arr)
            Geocalc.distance_between(self.coords, point_arr)
          end
          
          def nearby(max_miles_away = 50)
            location.nearby(max_miles_away, self.class.name.underscore)
          end
          
          def method_missing(method, *args, &block)
            return location.send(:nearby, args[0], $1.downcase.singularize) if method.to_s =~ /nearby_(\w+)/
            super(method, *args, &block)
          end
          
          module ClassMethods
            def nearby(coords, max_miles_away = 50)
              Location.nearby(coords, max_miles_away, self.name.underscore)
            end
            
            def method_missing(method, *args, &block)
              return Location.nearby(args[0], args[1], $1.downcase.singularize) if method.to_s =~ /nearby_(\w+)/
              super(method, *args, &block)
            end
          end
          
        end
        

And its cousin class, the Location model:

        class Location
          include Mongoid::Document
            
          field :coords, :type => Array, :default => lambda{ [199.9, 199.9] }
          index({ coords: "2d" }, { min: -200, max: 200 })
          
          field :place, type: String
          field :item_id, type: Integer
          field :item_class, type: String
          
          def self.nearby(coords, max_miles_away = 50, item_class = "user")
            # convert to lat/lng coord distance, as per http://www.mongodb.org/display/DOCS/Geospatial+Indexing
            max_miles_away = 50 unless max_miles_away.present?
            item_ids = self.where(:coords => {"$near" => coords , '$maxDistance' => max_miles_away.fdiv(69)}, :item_class => item_class).to_a
            item_ids.collect!(&:item_id)
            klass = item_class.classify.constantize
            klass.where("id IN (?)", item_ids)
          end
          
          def nearby(max_miles_away = 50, item_class = "user")
            return [] if self.coords.nil? || self.coords == [199.9, 199.9]
            self.class.nearby(self.coords, max_miles_away, item_class)
          end
          
          def self.method_missing(method, *args, &block)
            return self.nearby(args[0], args[1], $1.downcase.singularize) if method.to_s =~ /nearby_(\w+)/
            super(method, *args, &block)
          end
          
          def method_missing(method, *args, &block)
            return self.nearby(args[0], $1.downcase.singularize) if method.to_s =~ /nearby_(\w+)/
            super(method, *args, &block)
          end
          
        end

Here’s how it works:

  1. You create the location model using Mongoid. Mongo has built-in geo-indexing and geo-search capabilities, so we make a generic class to do that.
  2. Add the “Locatable” mixin to whatever class you want to make findable.
  3. Anywhere in your models / controllers, you can call “get_nearby_x” on your locatable class, where x is the underscored name of any other locatable class! For example, “get_nearby_users” and “get_nearby_groups” both work for any given user or group. Neat, right?

With Locatable, you can paginate and search through any model, starting from any model, as long as you at some point input coordinates for both of them. So far, it’s proving pretty nice.

Cheers,

Here’s what Typeset.css does:

It includes styles for ALL content-based semantic markup and resets layout-based styles (incorrectly) applied to user-generated content. It inherits font styles, allowing it to be dropped in anywhere on a page where content markup needs styles. It plays well with CSS resetters, normalizers bootstrappers, boilerplaters and other popular CSS frameworks. And it renders styles consistently across browsers.

This is basically a problem for every site I’ve ever done user generated content on. Good to see a quick, comprehensive solution.

One of the worst experiences is browsing for a file, and waiting for it to be uploaded. I wanted to avoid that at all cost. Ultimately, as a writer, I just want to drag an image onto the text and have everything else handled behind the scenes.

Did the same thing here at Jekyllhub. Drag and Drop for file uploading is too nice an experience to ignore. I put in a javascript spinner over the text to let the user know their file is being uploaded, but it shouldn’t get in the way of writing. I also have a regular file field as a fallback in case javascript is disabled or something.

Jekyll-Admin

Drop in code for Rails that allows you to edit your Jekyll.rb based blog. — Read more

via Github

Looks interesting.

What IS the P=NP problem exactly?

Well let’s break it down. It’s an equation problem, asking IF P is equal to NP. The point of it, is to prove either if P DOES equal NP or if P does NOT equal NP. No one has been able to prove either one. How’s that possible? There MUST be a right or wrong answer right? Wrong. lol.

Just had an interesting thing happen. Model.find_by_sql with a few joins (it’s a complicated query) occasionally returns empty rows in the middle of the result set. Well, guess what? Those empty results were still Model objects, with id and all other attributes set to nil.

I only found out about it when I hit upon this exception:

    NoMethodError: undefined method `join' for nil:NilClass

Deep in the routing code. Because the objects were not nil, it bypassed my usual nil catches. But journey still couldn’t make sense of it. Had to put a manual reject call at the end,

Blegh. Coding is hard.

Mastodon